package com.zx.centers.dataservice.mybatis.mapper.timing;

import com.zx.centers.dataservice.mybatis.domain.timing.TimingResult;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface TimingResultMapper {
    @Delete({
        "delete from timing_result",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into timing_result (id, task_code, ",
        "task_url, task_param, ",
        "task_class, task_result, ",
        "remark, task_result_mark, ",
        "create_time, update_time, ",
        "exception, task_name)",
        "values (#{id,jdbcType=BIGINT}, #{taskCode,jdbcType=VARCHAR}, ",
        "#{taskUrl,jdbcType=VARCHAR}, #{taskParam,jdbcType=VARCHAR}, ",
        "#{taskClass,jdbcType=VARCHAR}, #{taskResult,jdbcType=VARCHAR}, ",
        "#{remark,jdbcType=VARCHAR}, #{taskResultMark,jdbcType=BIT}, ",
        "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ",
        "#{exception,jdbcType=VARCHAR}, #{taskName,jdbcType=VARCHAR})"
    })
    int insert(TimingResult record);

    @InsertProvider(type=TimingResultSqlProvider.class, method="insertSelective")
    int insertSelective(TimingResult record);

    @Select({
        "select",
        "id, task_code, task_url, task_param, task_class, task_result, remark, task_result_mark, ",
        "create_time, update_time, exception, task_name",
        "from timing_result",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="task_code", property="taskCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="task_url", property="taskUrl", jdbcType=JdbcType.VARCHAR),
        @Result(column="task_param", property="taskParam", jdbcType=JdbcType.VARCHAR),
        @Result(column="task_class", property="taskClass", jdbcType=JdbcType.VARCHAR),
        @Result(column="task_result", property="taskResult", jdbcType=JdbcType.VARCHAR),
        @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR),
        @Result(column="task_result_mark", property="taskResultMark", jdbcType=JdbcType.BIT),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="exception", property="exception", jdbcType=JdbcType.VARCHAR),
        @Result(column="task_name", property="taskName", jdbcType=JdbcType.VARCHAR)
    })
    TimingResult selectByPrimaryKey(Long id);

    @UpdateProvider(type=TimingResultSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(TimingResult record);

    @Update({
        "update timing_result",
        "set task_code = #{taskCode,jdbcType=VARCHAR},",
          "task_url = #{taskUrl,jdbcType=VARCHAR},",
          "task_param = #{taskParam,jdbcType=VARCHAR},",
          "task_class = #{taskClass,jdbcType=VARCHAR},",
          "task_result = #{taskResult,jdbcType=VARCHAR},",
          "remark = #{remark,jdbcType=VARCHAR},",
          "task_result_mark = #{taskResultMark,jdbcType=BIT},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP},",
          "exception = #{exception,jdbcType=VARCHAR},",
          "task_name = #{taskName,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(TimingResult record);
}